package com.example.tests;

public class ContactData implements Comparable<ContactData> {
	private String id;
	private String firstName;
	private String lastName;
	private String address;
	private String phoneHome;
	private String phoneMobile;
	private String phoneWork;
	private String email;
	private String dayOfBirth;
	private String monthOfBirth;
	private String yearOfBirth;
	
	public void setId(String id) {
		this.id = id;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public void setPhoneHome(String phoneHome) {
		this.phoneHome = phoneHome;
	}

	public void setPhoneMobile(String phoneMobile) {
		this.phoneMobile = phoneMobile;
	}

	public void setPhoneWork(String phoneWork) {
		this.phoneWork = phoneWork;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setDayOfBirth(String dayOfBirth) {
		this.dayOfBirth = dayOfBirth;
	}

	public void setMonthOfBirth(String monthOfBirth) {
		this.monthOfBirth = monthOfBirth;
	}

	public void setYearOfBirth(String yearOfBirth) {
		this.yearOfBirth = yearOfBirth;
	}
	
	public String getId() {
		return id;
	}

	public String getFirstName() {
		return firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public String getAddress() {
		return address;
	}

	public String getPhoneHome() {
		return phoneHome;
	}

	public String getPhoneMobile() {
		return phoneMobile;
	}

	public String getPhoneWork() {
		return phoneWork;
	}

	public String getEmail() {
		return email;
	}

	public String getDayOfBirth() {
		return dayOfBirth;
	}

	public String getMonthOfBirth() {
		return monthOfBirth;
	}

	public String getYearOfBirth() {
		return yearOfBirth;
	}

	public ContactData(){
		
	}

	public ContactData(String firstName, String lastName, String address,
			String phoneHome, String phoneMobile, String phoneWork,
			String email, String dayOfBirth, String monthOfBirth,
			String yearOfBirth) {
		this.firstName = firstName;
		this.lastName = lastName;
		this.address = address;
		this.phoneHome = phoneHome;
		this.phoneMobile = phoneMobile;
		this.phoneWork = phoneWork;
		this.email = email;
		this.dayOfBirth = dayOfBirth;
		this.monthOfBirth = monthOfBirth;
		this.yearOfBirth = yearOfBirth;
	}
	
	
	public ContactData withId(String id) {
		this.id = id;
		return this;
	}
	

	public ContactData withFirstName(String firstName) {
		this.firstName = firstName;
		return this;
	}	
	
	public ContactData withLastName(String lastName) {
		this.lastName = lastName;
		return this;
	}	
	
	public ContactData withAddress(String address) {
		this.address = address;
		return this;
	}	
	public ContactData withPhoneHome(String phoneHome) {
		this.phoneHome = phoneHome;
		return this;
	}	
	
	public ContactData withPhoneMobile(String phoneMobile) {
		this.phoneMobile = phoneMobile;
		return this;
	}	
	
	public ContactData withPhoneWork(String phoneWork) {
		this.phoneWork = phoneWork;
		return this;
	}	
	
	public ContactData withEmail(String email) {
		this.email = email;
		return this;
	}	
	
	public ContactData withDayOfBirth(String dayOfBirth) {
		this.dayOfBirth = dayOfBirth;
		return this;
	}	
	
	public ContactData withMonthOfBirth(String monthOfBirth) {
		this.monthOfBirth = monthOfBirth;
		return this;
	}	
	
	public ContactData withYearOfBirth(String yearOfBirth) {
		this.yearOfBirth = yearOfBirth;
		return this;
	}	

	@Override
	public String toString() {
		return "ContactData [firstName=" + firstName + ", lastName=" + lastName
				+ ", phoneHome=" + phoneHome + ", email=" + email +  ", address ="+ address + ", phoneHome =" + phoneHome + ", phoneMobile ="
				+  ", phoneWork =" + phoneWork + ", dayOfBirth =" + dayOfBirth + ", monthOfBirth =" + monthOfBirth + ", yearOfBirth ="+ yearOfBirth + "]";
	}
	
	

	@Override
	public int hashCode() {
		//final int prime = 31;
		int result = 1;
		/*result = prime * result + ((email == null) ? 0 : email.hashCode());
		result = prime * result
				+ ((firstName == null) ? 0 : firstName.hashCode());
		result = prime * result
				+ ((lastName == null) ? 0 : lastName.hashCode());
		result = prime * result
				+ ((phoneHome == null) ? 0 : phoneHome.hashCode()); */
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ContactData other = (ContactData) obj;
		if (email == null) {
			if (other.email != null)
				return false;
		} else if (!email.equals(other.email))
			return false;
		if (firstName == null) {
			if (other.firstName != null)
				return false;
		} else if (!firstName.equals(other.firstName))
			return false;
		if (lastName == null) {
			if (other.lastName != null)
				return false;
		} else if (!lastName.equals(other.lastName))
			return false;
		if (phoneHome == null) {
			if (other.phoneHome != null)
				return false;
		} else if (!phoneHome.equals(other.phoneHome))
			return false;
	    if (phoneMobile == null) {
			if (other.phoneMobile != null)
				return false;
		} else if (!phoneMobile.equals(other.phoneMobile))
			return false;
		if (phoneWork== null) {
			if (other.phoneWork != null)
				return false;
		} else if (!phoneWork.equals(other.phoneWork))
			return false;
		if (address== null) {
			if (other.address != null)
				return false;
		} else if (!address.equals(other.address))
			return false;
		if (dayOfBirth== null) {
			if (other.dayOfBirth != null)
				return false;
		} else if (!dayOfBirth.equals(other.dayOfBirth))
			return false;
		if (monthOfBirth== null) {
			if (other.monthOfBirth != null)
				return false;
		} else if (!monthOfBirth.equals(other.monthOfBirth))
			return false;
		if (yearOfBirth== null) {
			if (other.yearOfBirth != null)
				return false;
		} else if (!yearOfBirth.equals(other.yearOfBirth))
			return false;
		
		return true;
	}

	@Override
	public int compareTo(ContactData other) {
		
		return this.lastName.toLowerCase().compareTo(other.lastName.toLowerCase());
	}
	
}